#!/usr/bin/env python
# -*-coding:utf-8-*-
# File    : liyuqi.py
# Date    : 2021-01-15
# Author  : Tom.Lee

#循环法生成fibo数列,
def fibo3(n:int):
    fiboarry = [0, 1]
    if n < 3: return fiboarry[:n]
    for i in range(2, n):
        fiboarry.append(fiboarry[i-1] + fiboarry[i-2])
    return fiboarry

#计算fibo数字
def fibo(n:int):
    if n == 2:return 1
    if n < 2:return 0
    return fibo(n-1)+ fibo(n-2)


#递归法生成fibo数列
def fibo2(n:int):
    if n == 1:
        return [0]
    elif n == 2:
        return [0, 1]
    elif n > 2:
        fiboarayy = fibo2(n-1)
        fiboarayy.append(fiboarayy[n-3] + fiboarayy[n-2])
        return fiboarayy
    else:
        raise ValueError("Bad numer!")



if __name__ == '__main__':
    print(fibo3(10))